package com.sunwayworld.basemodule.rm.equipment.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.sunwayworld.framework.at.annotation.AuditTrailType;
import com.sunwayworld.framework.at.annotation.AuditTrailEntry;
import com.sunwayworld.framework.spring.annotation.GikamBean;

import com.sunwayworld.basemodule.rm.equipment.dao.LimsEquipVerificationRecordDao;
import com.sunwayworld.basemodule.rm.equipment.bean.LimsEquipVerificationRecordBean;
import com.sunwayworld.basemodule.rm.equipment.service.LimsEquipVerificationRecordService;
import com.sunwayworld.framework.context.ApplicationContextHelper;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;

@Repository
@GikamBean
public class LimsEquipVerificationRecordServiceImpl implements LimsEquipVerificationRecordService {

    @Autowired
    private LimsEquipVerificationRecordDao limsEquipVerificationRecordDao;

    @Override
    @SuppressWarnings("unchecked")
    public LimsEquipVerificationRecordDao getDao() {
        return limsEquipVerificationRecordDao;
    }

    @Override
    @Transactional
    @AuditTrailEntry(AuditTrailType.INSERT)
    public Long insert(RestJsonWrapperBean jsonWrapper) {
        LimsEquipVerificationRecordBean limsEquipVerificationRecord = jsonWrapper.parseUnique(LimsEquipVerificationRecordBean.class);
        limsEquipVerificationRecord.setId(ApplicationContextHelper.getNextIdentity());
        getDao().insert(limsEquipVerificationRecord);
        return limsEquipVerificationRecord.getId();
    }

}
